package org.at;

import java.math.BigDecimal;

public class Apple extends Fruit{
    // 品种
    private String variety;
    // 产地
    private String origin;

    public Apple(BigDecimal price, BigDecimal discountRate, String variety, String origin) {
        if (discountRate.compareTo(BigDecimal.ZERO) <=0  || discountRate.compareTo(BigDecimal.ONE) > 0) {
            throw new IllegalArgumentException("折扣必须在0到1区间");
        }
        this.name = "苹果";
        this.price = price;
        this.discountRate = discountRate;
        this.variety = variety;
        this.origin = origin;
    }

    @Override
    public String getDescription() {
        return String.format("清脆多汁的%s%s，来自%s",variety,name,origin);
    }

    public String getOrigin() {
        return origin;
    }

    public void setOrigin(String origin) {
        this.origin = origin;
    }

    public String getVariety() {
        return variety;
    }

    public void setVariety(String variety) {
        this.variety = variety;
    }
}
